<!--
 * @Description: 新增或编辑
 * @Author: Liu Zhiwang
 * @Date: 2021-04-13 17:05:40
 * @LastEditTime: 2021-06-08 19:12:27
 * @LastEditors: Liu Zhiwang
-->
<template>
  <div>
    <base-dialog
      class="dialog_box"
      width="40%"
      :visible.sync="dialog.visible"
      :title="dialog.title"
      :loading="dialog.loading"
      :disabled="dialog.disabled"
      @updateData="updateData"
      @open="beforeOpenDialog">
      <el-form
        ref="dataForm"
        :model="dialog.form"
        :rules="dialog.rules"
        :disabled="dialog.disabled"
        label-width="100px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="厂家名称" prop="eqtName">
              <el-input v-model="dialog.form.eqtName" maxlength="20" type="text" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="厂家编号" prop="eqtNo">
              <el-input v-model="dialog.form.eqtNo" maxlength="20" type="text" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="联系人" prop="contacts">
              <el-input v-model="dialog.form.contacts" maxlength="20" type="text" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系人电话" prop="contactsPhone">
              <el-input v-model="dialog.form.contactsPhone" maxlength="20" type="text" />
            </el-form-item>
          </el-col>
        </el-row>
        <!--  <el-row>
          <el-col :span="12">
            <el-form-item label="是否系统" prop="isSystem">
              <el-switch v-model="dialog.form.isSystem" :active-value="1" :inactive-value="0" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否公用" prop="isPub">
              <el-switch v-model="dialog.form.isPub" :active-value="1" :inactive-value="0" />
            </el-form-item>
          </el-col>
        </el-row>-->
        <!-- <el-row>
          <el-col :span="12">
            <el-form-item label="启用" prop="status">
              <el-switch v-model="dialog.form.status" :active-value="1" :inactive-value="0" />
            </el-form-item>
          </el-col>
        </el-row>-->
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="dialog.form.remark" maxlength="500" type="textarea" resize="none" placeholder="请输入描述 300字以内" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </base-dialog>
  </div>
</template>
<script>
export default {
  components: {},
  props: {
    dialog: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {}
  },
  watch: {
    'dialog.visible'() {
      if (this.dialog.visible) {
        this.getList()
      }
    }
  },
  methods: {
    // 获取下拉数据、字典
    getList() {
    },

    // 回调方法
    updateData() {
      this.$refs.dataForm.validate((valid) => {
        if (valid) {
          this.dialog.loading = true
          this.$emit('updateData', this.dialog.form)
        }
      })
    },

    // 初始化
    beforeOpenDialog() {
      this.$nextTick(() => {
        this.$refs.dataForm.clearValidate()
      })
    }
  }
}
</script>
